package cn.edu.cqu.newslab.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;

import cn.edu.cqu.newslab.dao.IUserDao;
import cn.edu.cqu.newslab.model.User;
import cn.edu.cqu.newslab.service.IHelloWordService;

public class HelloWordServiceImpl implements IHelloWordService ,BeanNameAware {
	private static final Log logger = LogFactory.getLog(HelloWordServiceImpl.class);
	private IUserDao userDao;
	private String firstName;
	private String lastName;
	private String beanName;
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Override
	public void sayHello() {
		User user = userDao.findUserByFirstName(getFirstName());
		System.out.println(user.getFirstName()+" "+user.getLastName()+", hello world!");
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public void init() {
		if(logger.isInfoEnabled()){
			logger.info("##################Bean[" + this.beanName+"]init...");
		}
	}

	@Override
	public void destory() {
		if(logger.isInfoEnabled()){
			logger.info("##################Bean[" + this.beanName+"]destory...");
		}
	}

	@Override
	public void setBeanName(String name) {
		// TODO Auto-generated method stub
		this.beanName = name;
	}

}
